package com.x.servlet;

import com.x.service.user.UserService;
import com.x.service.user.UserServiceImpl;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;

/**
 * @author 13925
 */
public class AchievementDeleteByCodeAndCourseNameServlet extends HttpServlet {

    @Override
    protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        String code = null;
        String courseName = null;
        code = req.getParameter("code");
        courseName = req.getParameter("courseName");
        UserService userService = new UserServiceImpl();
        if (userService.deleteAchievementByCodeAndCourseName(code, courseName)) {
            resp.sendRedirect(req.getContextPath()+"/jsp/frameAdmin.jsp");
        } else {
            req.setAttribute("error","删除失败");
            req.getRequestDispatcher("achievementDelete.jsp").forward(req, resp);
        }

    }

    @Override
    protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        doGet(req, resp);
    }
}
